package com.hp.snap.gr.action.impl;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.hp.snap.gr.exception.ActionException;
import com.hp.snap.gr.model.jaxb.ActionType;
import com.hp.snap.gr.model.jaxb.GeneralActionType;
import com.hp.snap.gr.model.jaxb.ParameterType;
import com.hp.snap.gr.model.GRStatus;
import com.hp.snap.gr.utils.Constants;
import com.hp.snap.gr.utils.Utils;

public class GRStatusCodeActionHandler extends AbstractActionHandler {

    private static Logger logger = LoggerFactory.getLogger(GRStatusCodeActionHandler.class);
    
    @Override
    public void execute(ActionType action, Map<String, Object> actionPlanInputs, Map<String, Object> actionPlanOutputs)
            throws ActionException {
        GeneralActionType actionType = (GeneralActionType) action;
        List<ParameterType> parameterTypes = actionType.getParameter();
        Map<String, String> parameterMap = Utils.contructParamMap(parameterTypes);

        String sgmStatus = (String) actionPlanOutputs.get(Constants.STATUS_LOCAL_SGM);
        switch (GRStatus.valueOf(sgmStatus)){
        case STOPPED:
            Constants.CONSOLE.info("gr_status=1");
            break;
        case STARTING:
            Constants.CONSOLE.info("gr_status=2");
            break;
        case PAUSED:
            Constants.CONSOLE.info("gr_status=3");
            break;
        case STOPPING:
            Constants.CONSOLE.info("gr_status=4");
            break;
        case RUNNING:
            Constants.CONSOLE.info("gr_status=5");
            break;
        case ERROR:
            Constants.CONSOLE.info("gr_status=6");
            break;
        default:
            Constants.CONSOLE.info("gr_status=-1");
            break;
        }
    }
}
